<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>简历页面</title>
  </head>
  <body>

    <div class="head">
      当前登录: 
      <input type="text" class="user_name" value="wangc"/>
      <input type="button" value="上传简历" data-action="cv_upload" onclick="log(this)"></input>
    </div>
    <div class="body" data-job-code="alibaba">
      <span style="display: inline-block; width: 100px;">阿里巴巴</span>
      <button onclick="log(this)" data-action="job_retrieve">查看</button>
      <button onclick="log(this)" data-action="job_collect">收藏</button>
      <button onclick="log(this)" data-action="cv_send">投递简历</button>
    </div>
    <div class="body" data-job-code="tencent">
      <span style="display: inline-block; width: 100px;">腾讯</span>
      <button onclick="log(this)" data-action="cv_upload">查看</button>
      <button onclick="log(this)" data-action="job_collect">收藏</button>
      <button onclick="log(this)" data-action="cv_send">投递简历</button>
    </div>
    <div class="body" data-job-code="bytedance">
      <span style="display: inline-block; width: 100px;">今日头条</span>
      <button onclick="log(this)" data-action="cv_upload">查看</button>
      <button onclick="log(this)" data-action="job_collect">收藏</button>
      <button onclick="log(this)" data-action="cv_send">投递简历</button>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script>
      function log(e) {
          const action = e.getAttribute("data-action");
          const user_name = document.getElementsByClassName("user_name")[0].value;
          const job_code = e.parentElement.getAttribute("data-job-code");
          const time = new Date().toUTCString();
          const toLog = time + " " + user_name + " " + action + " " + job_code;
          postData("http://192.168.133.130:80/tolog", {toLog: toLog})
          window.location.href= "index.html";
      }
      function postData(url, data) {
        $.ajax({
          type: 'POST',
          url: url,
          data: data
        });
      }
    </script>
  </body>
</html>
